
import pytest

def setup_module():
    print ("setup_module():在模块最之前执行\n")

def teardown_module():
    print ("teardown_module：在模块之后执行")

def setup_function():
    print ("setup_function():每个方法之前执行")

def teardown_function():
    print ("teardown_function():每个方法之后执行\n")

def test_10():
    print ("正在执行方法中test1")
    x = "this"
    assert 'h' in x

class TestClass(object):

    def setup_class(self):
        print ("setup_class(self)：每个类之前执行一次")

    def teardown_class(self):
        print ("teardown_class(self)：每个类之后执行一次")

    def test_class(self):
        print("正在执行类中test1")
        x="this"
        assert 'h' in x

if __name__=="__main__":
    pytest.main(["-s","setup和teardown用法.py"])